package demo5;

public class Computer {
    public void open () {
        System.out.println("打开电脑");
    }
    public void close () {
        System.out.println("关闭电脑");
    }

    public void useDevice (IUSB iusb) {
        iusb.openDevice();
        if (iusb instanceof Mouse) {
            ((Mouse)iusb).click();
        } else if (iusb instanceof KeyBoard) {
            ((KeyBoard)iusb).knock();
        }
        iusb.closeDevice();
    }

}
